int arr[110] = { 0 };

void resolution(struct TreeNode* root, int* returnSize)
{
    if (root == NULL) return;
    arr[*returnSize] = root->val;
    (*returnSize)++;
    resolution(root->left, returnSize);
    resolution(root->right, returnSize);
}

int* preorderTraversal(struct TreeNode* root, int* returnSize) {
    *returnSize = 0;
    resolution(root, returnSize);
    return arr;
}

class Solution {
public:
    void resolution(TreeNode* root1)
    {
        if (root1 == NULL)return;
        resolution(root1->left);
        resolution(root1->right);
        if (root1) swap(root1->left, root1->right);
    }

    TreeNode* invertTree(TreeNode* root) {
        if (root == NULL)return root;
        resolution(root);
        return root;
    }
};

bool isSameTree(struct TreeNode* root1, struct TreeNode* root2)
{
    if (root1 == NULL && root2 == NULL)return true;
    if (root1 == NULL || root2 == NULL)return false;
    if (root1->val != root2->val)return false;
    return isSameTree(root1->left, root2->left) &&
        isSameTree(root1->right, root2->right);
}

bool isSubtree(struct TreeNode* root, struct TreeNode* subRoot) {
    if (root == NULL)return false;
    if (isSameTree(root, subRoot))return true;
    return isSubtree(root->left, subRoot) ||
        isSubtree(root->right, subRoot);
}

#include <stdio.h>

typedef struct TreeNode {
    char val;
    struct TreeNode* left;
    struct TreeNode* right;
}TreeNode;

TreeNode* CreateTree(char* a, int* pi)
{
    if (a[*pi] == '#') {
        (*pi)++;
        return NULL;
    }
    TreeNode* root = (TreeNode*)malloc(sizeof(TreeNode));
    root->val = a[(*pi)++];
    root->left = CreateTree(a, pi);
    root->right = CreateTree(a, pi);
    return root;
}

void InOrder(TreeNode* root)
{
    if (root == NULL)return;
    InOrder(root->left);
    printf("%c ", root->val);
    InOrder(root->right);
}

int main() {
    char arr[110] = { 0 };
    scanf("%s", arr);
    int i = 0;
    InOrder(CreateTree(arr, &i));
    return 0;
}